package com.uvnos4j.matilda.system.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.uvnos4j.matilda.commons.domain.BaseDomain;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.Date;

/**
 * 用户
 * <p>
 * Description:用户
 * </p>
 *
 * @author Guo.wl
 * @version v1.0.0
 * @see com.uvnos4j.matilda.system.domain
 * @since 2020-08-31 23:26:31
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "sys_user")
public class SysUser extends BaseDomain implements Serializable {
    private static final long serialVersionUID = 1L;
    @TableField(value = "username")
    private String username;
    @JsonIgnore
    @TableField(value = "password")
    private String password;
    /**
     * 昵称
     */
    @TableField(value = "nick_name")
    private String nickName;
    /**
     * 头像
     */
    @TableField(value = "icon")
    private String icon;
    /**
     * 邮箱
     */
    @TableField(value = "email")
    private String email;
    /**
     * 部门id
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @TableField(value = "dept_id")
    private Long deptId;
    /**
     * 备注信息
     */
    @TableField(value = "note")
    private String note;
    /**
     * 帐号启用状态：0->禁用；1->启用；2->锁定
     */
    @TableField(value = "status")
    private Integer status;
    /**
     * 密码到期时间
     */
    @TableField(value = "edit_pass_time")
    private Date editPassTime;
    /**
     * 最后登录时间
     */
    @TableField(value = "login_time")
    private Date loginTime;

    public boolean isAdmin() {
        return "admin".equals(username);
    }
}